package com.example.park2212.devices

import android.graphics.Color
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.lib_base.entity.DevicesBeanItem
import com.example.park2212.R

class DevicesAdapter:BaseQuickAdapter<DevicesBeanItem,BaseViewHolder>(R.layout.item_devices) {
    override fun convert(helper: BaseViewHolder, item: DevicesBeanItem) {
        helper.setText(R.id.devices_name,"项目名称/设备名称：${item.deviceName}")
        helper.setText(R.id.devices_type,"设备类型：${item.deviceType}")
        helper.setText(R.id.devices_address,"安装地点：${item.installationLocation}")
        helper.setText(R.id.devices_lu,"故障率：${item.failureRate}%")
        helper.setText(R.id.devices_status,item.status)
        val tv_status = helper.getView<TextView>(R.id.devices_status)

        if (item.status == "正常"){
            tv_status.setTextColor(Color.YELLOW)
            tv_status.setBackgroundResource(R.drawable.shape_solid_orange)
        }else if (item.status == "故障"){
            tv_status.setTextColor(Color.BLUE)
            tv_status.setBackgroundResource(R.drawable.shape_zhanyong)
        }
    }
}